package app.beit.fintrack.service.convert;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import app.beit.fintrack.bean.summary.SummaryTrackByStatusBean;
import app.beit.fintrack.entity.summary.SummaryTrackByStatus;

public class SummaryTrackByStatusConvert {

	/**
	 * Convert Entity To Bean
	 * 
	 * @param entity
	 * @return SummaryTrackRegupBean
	 */
	public static SummaryTrackByStatusBean entityToBean(final SummaryTrackByStatus entity) {
		final SummaryTrackByStatusBean bean = new SummaryTrackByStatusBean();
		
		bean.setBatchId(entity.getBatchId());
		bean.setExpression(entity.getExpression());
		bean.setRunDate(entity.getRunDate());
		bean.setAmount(entity.getAmount() == null || entity.getAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : entity.getAmount());
		
		return bean;
	}

	/**
	 * Convert Bean to Entity
	 * 
	 * @param bean
	 * @return SummaryTrackRegup
	 */
	public static SummaryTrackByStatus beanToEntity(final SummaryTrackByStatusBean bean){
		final SummaryTrackByStatus entity = new SummaryTrackByStatus();

		entity.setBatchId(bean.getBatchId());
		entity.setExpression(bean.getExpression());
		entity.setRunDate(bean.getRunDate());
		entity.setAmount(bean.getAmount() == null || bean.getAmount().toString().equalsIgnoreCase("") ? new BigDecimal("0") : bean.getAmount());

		return entity;
	}

	/**
	 * Convert List Entity to List Bean
	 * 
	 * @param entities
	 * @return List SummaryTrackRegupBean
	 */
	public static List<SummaryTrackByStatusBean> entityToBean(final List<SummaryTrackByStatus> entities){
		final List<SummaryTrackByStatusBean> beans = new ArrayList<SummaryTrackByStatusBean>();

		for (final SummaryTrackByStatus entity : entities) {
			beans.add(SummaryTrackByStatusConvert.entityToBean(entity));
		}

		return beans;
	}

	/**
	 * Convert List Bean to List Entity
	 * 
	 * @param beans
	 * @return List SummaryTrackRegup
	 */
	public static List<SummaryTrackByStatus> beanToEntity(final List<SummaryTrackByStatusBean> beans){
		final List<SummaryTrackByStatus> entities = new ArrayList<SummaryTrackByStatus>();

		for (final SummaryTrackByStatusBean bean : beans) {
			entities.add(SummaryTrackByStatusConvert.beanToEntity(bean));
		}

		return entities;
	}

}
